package demo;
//外部类
public class OuterClass {
    private String name;
    private static int serno=0;
    public OuterClass(){
        name="outerClass1";
    }
    //打印信息
    public void display(){
        System.out.println("name="+name+",serno="+serno);
    }
    public static int getSerno(){
        return serno;
    }
    public String getName(){
        return name;
    }

    public static class InnerClass1{
        private String innerName;

        public InnerClass1(){
          //  name=" InnerClass" 报错，无法访问外部类的非静态成员变量
            innerName="innerClass1";
        }

        public void showInfo(){
            //外部类getSerno是静态方法可以访问
            System.out.println("name="+innerName+",serno="+getSerno());
        }
        //而getName是静态方法无法访问
    }
}
